import { Node, Shape } from "@antv/x6";
import { nextId } from '../utils';
import { defaultPortGroup } from './_default';
import UserTaskIcon from '../icons/UserTask.svg';

export default class UserTask extends Shape.Rect{
  private static default:Node.Metadata = {
    width: 100,
    height: 60,
    label: '用户任务',
    markup: [
      { tagName: 'rect', selector: 'body' },
      { tagName: 'image', selector: 'img' },
      { tagName: 'text', selector: 'label' },
    ],
    attrs: {
      body: {
        rx: 6,
        ry: 6,
        stroke: '#5F95FF',
        fill: '#EFF4FF',
        strokeWidth: 1,
      },
      img: {
        x: 6,
        y: 6,
        width: 18,
        height: 18,
        'xlink:href': UserTaskIcon
      },
      label: {
        fontSize: 12,
        fill: '#262626',
      },
    },
    ports: {
      groups: {
        top: { ...defaultPortGroup, position: "top" },
        right: { ...defaultPortGroup, position: "right" },
        bottom: { ...defaultPortGroup, position: "bottom" },
        left: { ...defaultPortGroup, position: "left" }
      },
      items: [
        { id: "P0_0", group: "top" },
        { id: "P0_1", group: "top" },
        { id: "P0_2", group: "top" },
        { id: "P1_0", group: "right" },
        { id: "P1_1", group: "right" },
        { id: "P1_2", group: "right" },
        { id: "P2_0", group: "bottom" },
        { id: "P2_1", group: "bottom" },
        { id: "P2_2", group: "bottom" },
        { id: "P3_0", group: "left" },
        { id: "P3_1", group: "left" },
        { id: "P3_2", group: "left" },
      ],
    }
  }
  private static complement = (metadata: Node.Metadata={}):Node.Metadata=>{
    metadata.id = metadata.id || nextId();
    return Object.assign({},UserTask.default,metadata);
  }

  constructor(metadata: Node.Metadata={}){
    super(UserTask.complement(metadata));
  }

}